package de.szut.dqi10.brailletouchscreenreader.textprocessing;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;

import android.util.Log;

/**
 * Class that allows to get the appropriate contents of files used in this App
 * @author Marco Jedzig, Simon Grafenhorst, Felix Pusch
 *
 */
public class FileReader {

	private static final String TAG = "FileReader";

	public String getContent(File file) {
		StringBuilder content = new StringBuilder();
		
		try {
			BufferedReader br = new BufferedReader(new java.io.FileReader(file));
			Log.i(TAG, "Started file reading");
			String line;
			while(br.ready()) {
				line = br.readLine();
				content.append(line + "\n");
				Log.i(TAG,"Found line: " + line);
			}
			br.close();
			Log.i(TAG, "All content read");
		} catch (IOException e) {
			Log.e(TAG, "An Exception occured: ", e);
		}
		return content.toString();
	}
}
